import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;
import 'package:www.znpigai.teacher/utils/util.dart';

import 'state.dart';

Widget buildView(
    DemandState state, Dispatch dispatch, ViewService viewService) {
  return new Scaffold(
      appBar: new AppBar(
          centerTitle: true,
          elevation: 2.0,
          title: new Text(
            "作文要求",
            style: TextStyle(color: Colors.black54, fontSize: 18),
          )),
      body: SingleChildScrollView(
        child: Stack(
          children: <Widget>[
            Image.asset('assets/images/login_bg.png'),
            Column(
              children: <Widget>[
                SizedBox(height: 10),
                Card(
                    elevation: 4,
                    margin: EdgeInsets.fromLTRB(10, 4, 10, 10),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(16.0),
                    ),
                    child: Padding(
                      padding: EdgeInsets.all(20),
                      child: Column(
                        children: <Widget>[
                          Text('作文标题',
                              style: TextStyle(
                                  fontSize: 20, fontWeight: FontWeight.bold)),
                          new Divider(height: 1),
                          SizedBox(
                            width: double.infinity,
                            child: Text(state.homework.title),
                          ),
                          SizedBox(height: 20),
                          Text('作文要求',
                              style: TextStyle(
                                  fontSize: 20, fontWeight: FontWeight.bold)),
                          new Divider(height: 1),
                          Container(
                            width: double.infinity,
                            constraints: BoxConstraints(minHeight: 200.0),
                            child: Text(Util.plainText(state.homework.demand)),
                          ),
                        ],
                      ),
                    )),
                SizedBox(height: 10),
                SizedBox(
                  width: 200,
                  child: FlatButton(
                    padding: EdgeInsets.all(12),
                    color: Colors.blue,
                    textColor: Colors.white,
                    child: Text('确定'),
                    shape: RoundedRectangleBorder(
                        side: BorderSide(
                          color: Colors.white,
                          width: 0,
                        ),
                        borderRadius: BorderRadius.circular(20)),
                    onPressed: () {
                      Navigator.of(viewService.context).pop();
                    },
                  ),
                ),
              ],
            ),
          ],
        ),
      ));
}
